package com.rongx.reggie.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rongx.reggie.common.R;
import com.rongx.reggie.entity.OrderDetail;
import com.rongx.reggie.service.OrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/order")
@RequiredArgsConstructor
public class OrderController {
    private final OrderService orderService;

    @GetMapping("/page")
    public R<Page<OrderDetail>> page(int page, int pageSize) {
        Page<OrderDetail> pageInfo = new Page<>(page, pageSize);

        LambdaQueryWrapper<OrderDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(OrderDetail::getOrderId);

        orderService.page(pageInfo, queryWrapper);
        return R.success(pageInfo);
    }
}
